package Test;

import com.mapper.SStudentsMapper;
import com.pojo.SStudents;
import com.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

public class SStudentsTest {
    @Test
    public void selectSStudentsByIdTest(){
        SqlSession session = MyBatisUtils.getSqlSession();
        SStudentsMapper mapper = session.getMapper(SStudentsMapper.class);
        SStudents sstudents = mapper.selectSStudentsById(2);
        System.out.println(sstudents);
        session.close();
    }

    @Test
    public void updateSStudentsTest(){
        SqlSession session = MyBatisUtils.getSqlSession();
        SStudentsMapper mapper = session.getMapper(SStudentsMapper.class);
        SStudents sstudents = new SStudents();
        sstudents.setId(4);
        sstudents.setName("李雷");
        sstudents.setAge(21);
        int result = mapper.updateStudents(sstudents);
        if (result>0){
            System.out.println("成功插入"+result+"条数据");
        }else {
            System.out.println("插入数据失败");
        }
        System.out.println(sstudents.toString());
        session.commit();
        session.close();
    }

}
